package com.ly.controller;

import com.ly.constant.ResultCodeConstant;
import com.ly.pojo.domain.AboutUsDO;
import com.ly.pojo.dto.AboutUsDTO;
import com.ly.pojo.dto.DeleteGroup;
import com.ly.pojo.dto.RestResult;
import com.ly.pojo.dto.UpdateGroup;
import com.ly.pojo.query.AboutUsQuery;
import com.ly.pojo.query.QueryGroup;
import com.ly.service.AboutUsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.lang.Boolean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 关于我们管理
 *
 * @author Administrator
 * @date 2025-03-07 10:51:13
 */
@Tag(name = "关于我们管理")
@RequestMapping("about-us")
@RestController
public class AboutUsController {

    @Autowired
    private AboutUsService aboutUsService;

    /**
     * 编辑关于我们信息
     *
     * @param aboutUsDTO 关于我们信息编辑和添加的入参对象
     * @return
     */
    @RequestMapping(value = "/edit", method = RequestMethod.PUT)
    @Operation(summary = "编辑关于我们信息")
    @ResponseBody
    public RestResult<Boolean> editAboutUs(@RequestBody @Validated(UpdateGroup.class) AboutUsDTO aboutUsDTO) {
        Boolean result = aboutUsService.editAboutUs(aboutUsDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * 获取关于我们信息
     *
     * @param aboutUsQuery 关于我们信息查询的入参对象
     * @return
     */
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    @Operation(summary = "获取关于我们信息")
    public RestResult<AboutUsDO> aboutUsInfo(@Validated(QueryGroup.class) AboutUsQuery aboutUsQuery) {
        AboutUsDO result = aboutUsService.aboutUsInfo(aboutUsQuery);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * 获取最新关于我们信息
     *
     * @return
     */
    @RequestMapping(value = "/latest-info", method = RequestMethod.GET)
    @Operation(summary = "获取最新关于我们信息")
    public RestResult<AboutUsDO> latestAboutUsInfo() {
        AboutUsDO result = aboutUsService.latestAboutUsInfo();
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * 删除关于我们信息
     *
     * @param aboutUsQuery 关于我们信息查询的入参对象
     * @return
     */
    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    @Operation(summary = "删除关于我们信息")
    @ResponseBody
    public RestResult<Boolean> deleteAboutUs(@RequestBody @Validated(DeleteGroup.class) AboutUsQuery aboutUsQuery) {
        Boolean result = aboutUsService.deleteAboutUs(aboutUsQuery);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }
}
